package com.hualan.sfzy.service;
import com.hualan.sfzy.mapper.BaseMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
    public abstract class BaseServiceImp<T> implements BaseService<T> {
        @Autowired
        protected BaseMapper<T> baseMapper;

        @Override
        public int add(T entity) {
            return baseMapper.insert(entity);
        }

        @Override
        public int edit(T entity) {
            return baseMapper.update(entity);
        }

        @Override
        public int remove(Integer id) {
            return baseMapper.delete(id);
        }

        @Override
        public int removeBatch(Integer[] ids) {
            return baseMapper.deleteBatch(ids);
        }

        @Override
        public List<T>find() {
            return baseMapper.select(null);
        }
        @Override
        public T findById(Integer id) {
            return baseMapper.selectById(id);
        }
    }

